import request from '@/utils/request';

/**
 * 优惠券列表
 */
export async function couponOrderList(data) {
  const res = await request.post('/coupon/couponList', data);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 新增优惠券
export async function addCoupon(data) {
  const res = await request.post('/coupon/addCoupon', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 修改优惠券
export async function editCoupon(data) {
  const res = await request.post('/coupon/editCoupon', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 删除优惠券
export async function upCouponStatus(data) {
  const res = await request.post('/coupon/upCouponStatus', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
